
package com.bff.slimserver.musicjukebox.ui.components;

import java.awt.FlowLayout;
import java.awt.Graphics;
import javax.swing.DefaultListModel;
import javax.swing.JFrame;
import javax.swing.JList;
import javax.swing.JScrollBar;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
import javax.swing.JScrollPane;

/**
 *
 * @author bfindeisen
 */
public class RoundedScrollBar extends JScrollBar {

    @Override
    protected void paintComponent(Graphics g) {
        int width = getWidth();
        int height = getHeight();

        // Paint a rounded rectangle in the background.
        g.setColor(getBackground());
        g.fillRoundRect(0, 0, width, height, height, height);
        
        // Now call the superclass behavior to paint the foreground.
        super.paintComponent(g);
    }

    public static void main(String[] args) {
        JScrollBar jsb = new RoundedScrollBar();
        
        JList list = new JList();
        DefaultListModel model = new DefaultListModel();
        for (int i = 0; i < 100; i++) {
            model.addElement("Test" + i);
        }
        list.setModel(model);
        
        JScrollPane jsp = new JScrollPane(list);
        jsp.setVerticalScrollBar(jsb);
        
        JFrame f = new JFrame();
        f.setLayout(new FlowLayout());
        f.add(jsp);
        f.setSize(500,500);
        f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        f.setVisible(true);
    }
}
